<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-新建${name_china}</title>
 <%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>新建${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="addForm" method="post">
  <div id="left" style="width:80%;float:left">
	 <div class="form-wrapper">
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>特卖开始时间</p>
	        <input type="text" id="specialTime" name="specialTime" class="summer-input summer-validatebox" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	       	<input type="text" id="startTime" name="startTime" class="summer-input summer-validatebox" /> 	       
	      </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>特卖结束时间</p>
	        <input type="text" id="specialEndTime" name="specialEndTime" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[10]']" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	       	<input type="text" id="endTime" name="endTime" class="summer-input summer-validatebox" /> 	       
	     </div>
	     
	 <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
  </div>
	
</form>
<script>
    var  permission = CommonUtil.getPermission('${name_english}');
    $(function () {
    	
    	//T_DM_T_MARKET_SPECIAL_TIME
    	//初始化下拉选项
     	  $('#spuPlatform').combobox({
               valueField : 'code',
               textField : 'name',
               url : COMMON_URL.getCode + '?type=T_DM_T_MARKET_SPECIAL_SPU_PLATFORM'
           });
    	 //开始整点时间
     	 $('#startTime').combobox({
             valueField : 'code',
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_DM_T_MARKET_SPECIAL_TIME'
         });
     	 //结束
     	 $('#endTime').combobox({
             valueField : 'code',
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_DM_T_MARKET_SPECIAL_TIME'
         });
    	//初始化funcbar
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:add']
        }));
   	     	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:add"]', {isContinue: false},  submit);
    	
    	//返回按钮
    	$('#backBtn,#goBack').on('click',backMain);
    	
    });
    
    
    //表单提交
    function submit(event) {
    	var startTime = $("#startTime").val();
    	var endTime = $("#endTime").val();
    	$("#addForm").form({
        	 buttons : ['#saveBtn','#saveBtnContinue'],
             ajax: {
                 url: CONST_URL.TIME_ADD
             },
             data:{
    				"startTime": trimSpace($('#startTime').val()), 
    				"endTime": trimSpace($('#endTime').val())
    			},
             onSubmitSuccess: function (data) {
            	 $.stip({
  	                type:'ok',//显示类型 有info、 ok、 danger
  	                text: '保存成功！',
  	                onBeforeHide: function () {
  	            	  var isContinue = event.data.isContinue;
                   	  if (isContinue) {
                          resetForm();
                   	  } else {
                   		  backMain();
                   	  }
  	               }
              	});
              }
         }).form("submit");
    }
    
    //保存并继续清空form
    function resetForm(){
        //$('#xm,#zw,#cs,#bgdh,#sjhm').val('');
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    
   
    //请求url
    var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}init",
       	TIME_ADD: basePath + "${common_url}timeAdd"
    };
    
</script>
</body>
</html>